<?php

namespace App\Http\Controllers;

use App\Models\Banner;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

class BannerController extends BaseController
{


    public function preview()
    {

        //$a = $this->preOrder();
        $param = [
            "reqHeader" => [
                "transTime" => '20240518174228',
                "reqId" => "631000000000247"
            ],
            "reqBody" =>  [
                "termId" => "77777771",
                "mchtCd" => "555555555555555",
            ],
        ];

        $param['reqSign'] = $this->getSign($param);


        $result = Http::post('https://test-gap.easypay.com.cn:8443/sklOrder/termSettlement/preview',$param)->json();
        dd($result);
    }

    public function index(Request $request)
    {
        $param = $this->validate($request,[
            'ad_hierarchy_id' => 'required|integer'
        ]);

       $banners =  Banner::query()
                         ->where('ad_hierarchy_id',$param['ad_hierarchy_id'])
                         ->where('status',1)
                         ->orderBy('id')
                         ->orderByDesc('id')
                         ->get();

       return $this->success($banners);
    }
}
